<template>
  <div
    class="swiper-container"
    @mouseenter="swiper.autoplay.stop()"
    @mouseleave="swiper.autoplay.start()"
    ref="swp"
  >
    <div class="swiper-wrapper">
      <div class="swiper-slide" v-for="img in RC_data" :key="img.id">
        <img :src="img.picUrl" alt="" />
      </div>
    </div>
    <!-- Add Pagination -->
    <div class="swiper-pagination"></div>
  </div>
</template>

<script>
import Swiper from "swiper";
import "swiper/css/swiper.min.css";
export default {
  name: "Carousel",
  props: ["RC_data"],
  mounted() {
    // this.swiper = new Swiper(this.$refs.swp, {
    //   spaceBetween: 30,
    //   pagination: {
    //     //小圆点
    //     el: ".swiper-pagination",
    //     clickable: true,
    //   },
    //   // autoplay:false
    //   autoplay: {
    //     // 自动轮播
    //     delay: 2000,
    //   },
    // });
  },
  watch: {
    RC_data: {
      handler() {
        this.$nextTick(() => {
          this.swiper = new Swiper(this.$refs.swp, {
            spaceBetween: 30,
            pagination: {
              //小圆点
              el: ".swiper-pagination",
              clickable: true,
            },
            // autoplay:false
            autoplay: {
              // 自动轮播
              delay: 2000,
            },
          });
        });
      },
    },
  },
};
</script>
<style>
</style>